package com.movitech.mobile.cz.base.supplier.service;

import com.baomidou.mybatisplus.service.IService;
import com.movitech.mobile.cz.base.supplier.entity.SMyDeals;
import com.movitech.mobile.cz.base.supplier.entity.ext.ExtSMyDeals;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 我的待办已办 服务类
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-03-06
 */
public interface SMyDealsService extends IService<SMyDeals> {

    boolean saveSMyDeals(SMyDeals sMyDeals);
    
    boolean updateSMyDealsById(SMyDeals sMyDeals);
    
    /**
     * 更新已办，添加待办
     * @param relatedId
     * @param subRelatedId 
     * @param dealType
     * @param userIds 新增待办用户id
     * @param dealActionType 
     * @param subDealType 
     * @param dealTile 
     * @param userId 更新已办用户id
     * @param batchUpdate 批量更新待办
     * @param thirdRelatedId 
     * @return
     */
    boolean dealMyDeals(String relatedId, String subRelatedId, int dealType, String[] userIds, 
    		int subDealType, int dealActionType, String dealTile, String userId, boolean batchUpdate, String thirdRelatedId);

    boolean dealMyDeals(String relatedId, String subRelatedId, int dealActionType);

    /**
     * 获取我的待办/已办
     * @param map 
     * @return
     */
	List<SMyDeals> getMyDealsListByUserAndStatus(Map<String, Object> map);

    List<SMyDeals> getOuterDealsList(Map<String, Object> map);

    boolean deleteSmyDealsById(String id);
    boolean updateDeleteStatusByRelateIdAndTaskId(String relateId,String taskId,Integer deleteFlag);
    boolean deleteNoDonedByFormId(String relateId);

    boolean deleteByEntityExceptUsers(SMyDeals sMyDeals,List<String> exceptUserIds);
    boolean deleteBatchByEntityAndUsers(SMyDeals sMyDeals,List<String> userids);

    boolean doneByEntityAndUsers(SMyDeals sMyDeals,List<String> userids,String remak);
    boolean doneById(String id);

    SMyDeals selectUntreatedById(String id);

    SMyDeals selectById(String id);

    SMyDeals selectOneByEntity(SMyDeals sMyDeals);

    /**
     * 查询待办/已办数量
     * @param userId
     * @param dealType 类型（1：供方，2：采购）
     * @param dealSubTypeList 子类型
     * @param includeFlag 是否包含
     * @param doneFlag 是否处理（0：否，1：是）
     * @return
     */
	int getToDoOrDoneListCounts(String userId, int dealType, List<Integer> dealSubTypeList, boolean includeFlag, int doneFlag);

	long getMyDealListByParamsCounts(Map<String, Object> map);

	List<ExtSMyDeals> getMyDealListByParams(Map<String, Object> map);

	int updateSMyDealsByEntity(SMyDeals sMyDeals);


    void updateUserByEntity(String userId, SMyDeals sMyDealsWhere);
    boolean isDone(String userId,String rcId,String subRcId,Integer actionType);
    boolean isDone(String dealId);
}
